package com.ysh.product;

import com.github.pagehelper.PageHelper;
import com.lyw.mapper.EbProductMapper;
import com.lyw.model.EbProduct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:xml/spring-dao.xml")
public class ysh2 {
    @Autowired
    private EbProductMapper ebProductMapper;

    @Test //这里不能省略 否则运行报错
    public void whenPageSuccess() {
        //1.构建高级查询的exmpale对象
        PageHelper.startPage(2, 3);
        //2.查收方法直接调用查询所有就可以了
        List<EbProduct> ebProducts = ebProductMapper.selectByExample(null);
        System.out.println("查询第2页 每页显示3条的所有商品信息为：\n" + ebProducts);
    }
}
